package com.baseweb.webadmin.core.util;


import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

/**
 * @description: 分页返回bean
 * @author: xiaoqiang
 * @time: 2017-07-08 16:21
 */
public class ResultPage<T> {
    /**
     * 总条数
     */
    long total;
    /**
     * 总页数
     */
    int totalPage;
    /**
     * 每页显示的条数
     */
    int pageSize;

    /**
     * 当前页码
     */
    int nowPage;

    /**
     * 冗余字段
     */
    BigDecimal temp;

    BigDecimal temp1;
    /**
     * 分页数据
     */
    List<T> rows;

    public ResultPage() {
        this.total = 0L;
        this.pageSize = 10;
        this.rows = new ArrayList<>();
    }

    public ResultPage(long total, int pageSize, List<T> rows) {
        this.total = total;
        this.pageSize = pageSize;
        this.rows = rows;
    }

    public ResultPage(long total, int pageSize, int nowPage, List<T> rows) {
        this.total = total;
        this.pageSize = pageSize;
        this.nowPage = nowPage;
        this.rows = rows;
    }

    public ResultPage(long total, BigDecimal temp1, BigDecimal temp,int pageSize, int nowPage,  List<T> rows) {
        this.total = total;
        this.temp1 = temp1;
        this.pageSize = pageSize;
        this.nowPage = nowPage;
        this.temp = temp;
        this.rows = rows;
    }

    public int getNowPage() {
        return nowPage;
    }

    public void setNowPage(int nowPage) {
        this.nowPage = nowPage;
    }

    public long getTotal() {
        return total;
    }

    public void setTotal(long total) {
        this.total = total;
    }

    public int getTotalPage() {
        return (int) ((this.total + this.pageSize - 1) / this.pageSize);
    }

    public void setTotalPage(int totalPage) {
        this.totalPage = totalPage;
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public List<T> getRows() {
        return rows;
    }

    public void setRows(List<T> rows) {
        this.rows = rows;
    }

    public BigDecimal getTemp() {
        return temp;
    }

    public void setTemp(BigDecimal temp) {
        this.temp = temp;
    }

    public BigDecimal getTemp1() {
        return temp1;
    }

    public void setTemp1(BigDecimal temp1) {
        this.temp1 = temp1;
    }
}
